package cn.iocoder.yudao.module.system.service.gugu;

import cn.iocoder.yudao.module.system.controller.admin.gugu.vo.StructuredUserDataReqVO;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * getAllSuitableMajors 分页功能使用示例
 */
public class AllSuitableMajorsPageExample {

    /**
     * 示例：创建分页请求的结构化用户数据
     */
    public static Map<String, StructuredUserDataReqVO.QuestionAnswer> createExampleUserAnswers() {
        Map<String, StructuredUserDataReqVO.QuestionAnswer> userAnswers = new HashMap<>();

        // 1. 学生所处的高考省份
        StructuredUserDataReqVO.QuestionAnswer provinceAnswer = new StructuredUserDataReqVO.QuestionAnswer();
        provinceAnswer.setQuestionContent("学生所处的高考省份");
        provinceAnswer.setAnswer("辽宁");
        userAnswers.put("1", provinceAnswer);

        // 2. 学生性别
        StructuredUserDataReqVO.QuestionAnswer genderAnswer = new StructuredUserDataReqVO.QuestionAnswer();
        genderAnswer.setQuestionContent("学生性别");
        genderAnswer.setAnswer("我是女生");
        userAnswers.put("2", genderAnswer);

        // 3. 学生选科
        StructuredUserDataReqVO.QuestionAnswer subjectsAnswer = new StructuredUserDataReqVO.QuestionAnswer();
        subjectsAnswer.setQuestionContent("学生选科");
        subjectsAnswer.setAnswer(Arrays.asList("历史", "生物", "政治"));
        userAnswers.put("3", subjectsAnswer);

        // 5. 高考总分
        StructuredUserDataReqVO.QuestionAnswer totalScoreAnswer = new StructuredUserDataReqVO.QuestionAnswer();
        totalScoreAnswer.setQuestionContent("高考总分");
        totalScoreAnswer.setAnswer("538");
        userAnswers.put("5", totalScoreAnswer);

        // 7. 意向专业
        StructuredUserDataReqVO.QuestionAnswer interestedMajorsAnswer = new StructuredUserDataReqVO.QuestionAnswer();
        interestedMajorsAnswer.setQuestionContent("意向专业");
        interestedMajorsAnswer.setAnswer(Arrays.asList("护理学"));
        userAnswers.put("7", interestedMajorsAnswer);

        return userAnswers;
    }

    /**
     * 示例：分页查询冲刺专业
     */
    public static void demonstrateRushMajorsPagination() {
        System.out.println("=== 分页查询冲刺专业示例 ===");
        System.out.println("请求参数:");
        System.out.println("{");
        System.out.println("  \"pageNo\": 1,");
        System.out.println("  \"pageSize\": 10,");
        System.out.println("  \"majorType\": \"rush\",");
        System.out.println("  \"userAnswers\": { ... }");
        System.out.println("}");
        System.out.println();
        System.out.println("预期响应:");
        System.out.println("- 返回第1页的10条冲刺专业数据");
        System.out.println("- 包含完整的统计信息（冲稳保各类专业数量）");
        System.out.println("- currentMajorType: \"rush\"");
        System.out.println();
    }

    /**
     * 示例：分页查询稳妥专业
     */
    public static void demonstrateStableMajorsPagination() {
        System.out.println("=== 分页查询稳妥专业示例 ===");
        System.out.println("请求参数:");
        System.out.println("{");
        System.out.println("  \"pageNo\": 2,");
        System.out.println("  \"pageSize\": 20,");
        System.out.println("  \"majorType\": \"stable\",");
        System.out.println("  \"userAnswers\": { ... }");
        System.out.println("}");
        System.out.println();
        System.out.println("预期响应:");
        System.out.println("- 返回第2页的20条稳妥专业数据");
        System.out.println("- 包含完整的统计信息");
        System.out.println("- currentMajorType: \"stable\"");
        System.out.println();
    }

    /**
     * 示例：分页查询保底专业
     */
    public static void demonstrateSafeMajorsPagination() {
        System.out.println("=== 分页查询保底专业示例 ===");
        System.out.println("请求参数:");
        System.out.println("{");
        System.out.println("  \"pageNo\": 1,");
        System.out.println("  \"pageSize\": 15,");
        System.out.println("  \"majorType\": \"safe\",");
        System.out.println("  \"userAnswers\": { ... }");
        System.out.println("}");
        System.out.println();
        System.out.println("预期响应:");
        System.out.println("- 返回第1页的15条保底专业数据");
        System.out.println("- 包含完整的统计信息");
        System.out.println("- currentMajorType: \"safe\"");
        System.out.println();
    }

    /**
     * API 调用示例
     */
    public static void demonstrateApiUsage() {
        System.out.println("=== API 调用示例 ===");
        System.out.println("接口地址: POST /system/metadata/ceemajor/all-suitable/page");
        System.out.println();
        System.out.println("curl 示例:");
        System.out.println("curl -X POST \"http://localhost:8080/system/metadata/ceemajor/all-suitable/page\" \\");
        System.out.println("  -H \"Content-Type: application/json\" \\");
        System.out.println("  -d '{");
        System.out.println("    \"pageNo\": 1,");
        System.out.println("    \"pageSize\": 10,");
        System.out.println("    \"majorType\": \"rush\",");
        System.out.println("    \"userAnswers\": {");
        System.out.println("      \"1\": {");
        System.out.println("        \"questionContent\": \"学生所处的高考省份\",");
        System.out.println("        \"answer\": \"辽宁\"");
        System.out.println("      },");
        System.out.println("      \"5\": {");
        System.out.println("        \"questionContent\": \"高考总分\",");
        System.out.println("        \"answer\": \"538\"");
        System.out.println("      }");
        System.out.println("    }");
        System.out.println("  }'");
        System.out.println();
    }

    /**
     * 分页功能优势说明
     */
    public static void demonstrateAdvantages() {
        System.out.println("=== 分页功能优势 ===");
        System.out.println("1. 减少数据传输量");
        System.out.println("   - 原接口可能返回数百条专业数据");
        System.out.println("   - 分页接口每次只返回指定数量的数据");
        System.out.println();
        System.out.println("2. 提升用户体验");
        System.out.println("   - 支持按专业类型分别查看");
        System.out.println("   - 前端可以实现分页展示");
        System.out.println();
        System.out.println("3. 灵活的查询方式");
        System.out.println("   - 可以只查看感兴趣的专业类型");
        System.out.println("   - 支持不同的分页大小");
        System.out.println();
        System.out.println("4. 保持完整信息");
        System.out.println("   - 仍然返回所有类型的统计数量");
        System.out.println("   - 保留原有的查询信息说明");
        System.out.println();
    }

    public static void main(String[] args) {
        demonstrateRushMajorsPagination();
        demonstrateStableMajorsPagination();
        demonstrateSafeMajorsPagination();
        demonstrateApiUsage();
        demonstrateAdvantages();
    }
}
